//
//  JQProgressHUD.m
//  Vdianjing
//
//  Created by appbegin on 15/8/21.
//  Copyright (c) 2015年 Vdianjing. All rights reserved.
//

#import "JQProgressHUD.h"
#import "JGProgressHUD.h"

//static JGProgressHUDStyle _style;
static JGProgressHUDInteractionType _interaction;
static BOOL _zoom;
static BOOL _dim;
static BOOL _shadow;
static UIWindow *_window;
@interface JQProgressHUD ()
{
    
}
@end

@implementation JQProgressHUD

+ (JGProgressHUD *)shared
{
    JGProgressHUD *HUD = [[JGProgressHUD alloc] initWithStyle:JGProgressHUDStyleDark];
    HUD.interactionType = _interaction;
    if (_zoom) {
        JGProgressHUDFadeZoomAnimation *an = [JGProgressHUDFadeZoomAnimation animation];
        HUD.animation = an;
    }
    
    if (_dim) {
        HUD.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f];
    }
    
    if (_shadow) {
        HUD.HUDView.layer.shadowColor = [UIColor blackColor].CGColor;
        HUD.HUDView.layer.shadowOffset = CGSizeZero;
        HUD.HUDView.layer.shadowOpacity = 0.4f;
        HUD.HUDView.layer.shadowRadius = 8.0f;
    }
    
    //    HUD.delegate = self;
    
    return HUD;
}

+ (void)dismiss
{
    
}
+ (void)show:(NSString *)status
{
    
}

+ (void)showSuccessMessage:(NSString *)msg
{
    JGProgressHUD *HUD = [[self class] shared];
    
    HUD.textLabel.text = msg;
    HUD.indicatorView = [[JGProgressHUDSuccessIndicatorView alloc] init];
    
    HUD.square = NO;
    
    //    [HUD showInView:parentView];
    id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
    if ([delegate respondsToSelector:@selector(window)])
        _window = [delegate performSelector:@selector(window)];
    else _window = [[UIApplication sharedApplication] keyWindow];
    [HUD showInView:_window];
    [HUD dismissAfterDelay:1.5];
}

+ (void)showErrorMessage:(NSString *)msg
{
    JGProgressHUD *HUD = [[self class] shared];
    
    HUD.textLabel.text = msg;
    HUD.indicatorView = [[JGProgressHUDErrorIndicatorView alloc] init];
    
    HUD.square = NO;
    
    //    [HUD showInView:parentView];
    id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
    if ([delegate respondsToSelector:@selector(window)])
        _window = [delegate performSelector:@selector(window)];
    else _window = [[UIApplication sharedApplication] keyWindow];
    [HUD showInView:_window];
    [HUD dismissAfterDelay:1.5];
}

@end
